package com.bolehui.web;

import com.bolehui.base.result.Result;
import com.bolehui.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.UnsupportedEncodingException;

/**
 * @author chendongjie     email:chendongjie@gz.iscas.ac.cn
 * @version 1.0
 * @ClassName UploadFile
 * @Description 上传文件
 * @createTime 2024/12/2 10:33
 * Copyright (C) 2021-2022 CASEEDER, All Rights Reserved.
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 */
@RestController
@RequestMapping("/upload/uploadFile.do")
public class UploadFileController {



    @Autowired
    private UploadService uploadService;

    /**
     * 上传文件
     * @param file
     * @return
     */
    @RequestMapping(params = "action=uploadResume")
    public Result uploadResume(@RequestParam("file") MultipartFile file, Long id){
        return uploadService.upload(file, id);
    }

    /**
     * 查询已上传文件
     */
    @RequestMapping(params = "action=queryResume")
    public Result queryResume(Long id){
        return uploadService.queryResume(id);
    }

    /**
     * 删除文件
     * @param id
     * @return
     */
    @RequestMapping(params = "action=deleteResume")
    public Result deleteResume(Long id) throws Exception {
        return uploadService.deleteResume(id);
    }

    /**
     * 文件预览
     * @param id
     * @return
     */
    @RequestMapping(params = "action=previewImage")
    public Result previewImage(Long id) throws UnsupportedEncodingException {
        return uploadService.previewImage(id);
    }
}
